Skip to content

Conversation

james7132
Copy link
Contributor

Use Pin<&'a State> to point to the state instead of cloning Arcs, this should reduce the amount of atomic operations required.

This should be sound given that the state are never moved until the Executor is dropped. This still uses Arc instead of Box as miri will treat a former Box as a uniquely owned pointer and cannot be shared (backed by Unique vs Shared).

Benchmark results:

group                                               master                                 pinned-state
-----                                               ------                                 ------------
executor::create                                    1.06  944.7±129.72ns        ? ?/sec    1.00   889.7±17.24ns        ? ?/sec
multi_thread/executor::channels                     1.00     35.5±0.76ms        ? ?/sec    1.00     35.7±0.75ms        ? ?/sec
multi_thread/executor::spawn_batch                  1.23     27.8±5.06µs        ? ?/sec    1.00     22.6±9.96µs        ? ?/sec
multi_thread/executor::spawn_many_local             1.08     23.2±0.57ms        ? ?/sec    1.00     21.5±0.79ms        ? ?/sec
multi_thread/executor::spawn_one                    1.07   995.0±35.82ns        ? ?/sec    1.00   929.5±26.16ns        ? ?/sec
multi_thread/executor::spawn_recursively            1.06    144.8±1.28ms        ? ?/sec    1.00    136.8±1.56ms        ? ?/sec
multi_thread/executor::web_server                   1.00     50.9±1.03ms        ? ?/sec    1.00     51.1±1.80ms        ? ?/sec
multi_thread/executor::yield_now                    1.00     20.2±0.61ms        ? ?/sec    1.01     20.4±0.28ms        ? ?/sec
single_thread/executor::channels                    1.00     14.4±0.41ms        ? ?/sec    1.07     15.4±0.66ms        ? ?/sec
single_thread/executor::spawn_batch                 1.08    20.2±11.74µs        ? ?/sec    1.00     18.7±8.31µs        ? ?/sec
single_thread/executor::spawn_many_local            1.11      5.4±0.72ms        ? ?/sec    1.00      4.9±0.24ms        ? ?/sec
single_thread/executor::spawn_one                   1.02  1422.7±75.41ns        ? ?/sec    1.00  1388.6±42.78ns        ? ?/sec
single_thread/executor::spawn_recursively           1.03     22.6±1.05ms        ? ?/sec    1.00     21.9±1.11ms        ? ?/sec
single_thread/executor::web_server                  1.03     23.0±0.22ms        ? ?/sec    1.00     22.3±0.31ms        ? ?/sec
single_thread/executor::yield_now                   1.02      4.1±0.06ms        ? ?/sec    1.00      4.0±0.03ms        ? ?/sec

@james7132 james7132 requested a review from notgull August 14, 2025 01:42
@notgull
Copy link
Member

notgull commented Aug 16, 2025

I intend to review this, but I am preoccupied at the moment.

Copy link
Member

@notgull notgull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, one minor nitpick.

Copy link
Member

@notgull notgull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Rebase and I will merge. (Or you can too.)

@james7132 james7132 merged commit c10412c into smol-rs:master Aug 27, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants